// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "InventoryItemStruct.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "UnrealString.h"
#include "DataTableFunctions.generated.h"

UCLASS()
class RPG_API UDataTableFunctions : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

	static const FString ContextString;

public:
	UFUNCTION(BlueprintCallable, BlueprintPure, Category = Inventario)
	static UDataTable* GetItensDataTable();

	UFUNCTION(BlueprintCallable, BlueprintPure, Category = Inventario)
	static FInventoryItemStruct GetItemData(const int32& ItemID);

	static FInventoryItemStruct* GetItemDataPtr(const int32& ItemID);

	template <class T = UObject>
	static T* GetAssetPtr(TAssetPtr<T>& AssetPtr)
	{
		if (!AssetPtr.IsValid() && AssetPtr.IsPending())
		{
			StaticLoadObject(T::StaticClass(), NULL, *AssetPtr.ToStringReference().ToString());
		}

		return AssetPtr.Get();
	}
	
};